package common

import (
	_ "github.com/go-sql-driver/mysql"
	"github.com/jinzhu/gorm"
)

var (
	db *gorm.DB
	err error
)

func init(){

	//给全局变量db赋值，连接mysql驱动
	db, err = gorm.Open("mysql", "root:root@/go_mysql?charset=utf8&parseTime=True&loc=Local")
	if err != nil {
		panic(err)
	}

}

func GetDB() *gorm.DB{
	return db
}
